subscribeModule.controller('subscribeWidget', function($scope, sharedSubscribers) {
  sharedSubscribers.getSubscribers().then(function(subscribers) {
    $scope.subscribers = subscribers;
//    console.log($scope.subscribers);
  });

  $scope.$on('handleSubscribersBroadcast', function(event, subscribers) {
    $scope.subscribers = subscribers;
  });

  $scope.addEmail = function(emailAddress) {
    if (emailAddress && emailAddress != '') {
      var validEmail = validateEmail(emailAddress);
      if (validEmail) {
        sharedSubscribers.addSubscriber(emailAddress);
      } else {
        alert('Not a valid entry');
      }
    } else {
      alert('Blank entry - invalid');
    }
    return false;
  }
});